package com.qf.android.huihui.adapter.information;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.qf.android.huihui.R;
import com.qf.android.huihui.bean.show.MenuItemBean;

import java.util.List;

/**
 * Created by lx on 2017/1/9.
 */

public class MenuAdapter1 extends BaseAdapter {
    private List<MenuItemBean> list;
    private Context context;

    public MenuAdapter1(List<MenuItemBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.menu_item_layout, viewGroup, false);
            holder = new ViewHolder();
            holder.tv = (TextView) view.findViewById(R.id.menu_tv);
            holder.iv = (ImageView) view.findViewById(R.id.menu_iv);
            view.setTag(holder);
        } else
            holder = (ViewHolder) view.getTag();
        if(i==0) {
            holder.tv.setText(list.get(i).getName());
            holder.tv.setTextSize(22);
            holder.iv.setPadding(10, 10, 10, 10);
            holder.iv.setImageBitmap(list.get(i).getMap2());
        }
        else {
            holder.tv.setText(list.get(i).getName());
            holder.tv.setTextSize(15);
            holder.iv.setPadding(33, 33, 33, 33);
            holder.iv.setImageBitmap(list.get(i).getMap());
        }
        return view;
    }

    class ViewHolder {
        private TextView tv;
        private ImageView iv;
    }
}
